//
//  MineShareHeaDerView.swift
//  HappyEat
//
//  Created by ctx2016 on 17/1/11.
//  Copyright © 2017年 陌路是我. All rights reserved.
//

import UIKit

//protocol MineShareHeaderDelegate {
//    func returnHeightOfHeaderView(_ height:CGFloat)
//}
class MineShareHeaDerView: UIView {
    var titleView:UIImageView = UIImageView.init(image: UIImage.init(named: ""))
    var bgView:UIView = UIView.init()
    var infoLabel:UILabel = UILabel.init()
    var noticeLabel:UILabel = UILabel.init()
    var height:CGFloat = 0
//    var delegate:MineShareHeaderDelegate?
    override init(frame: CGRect) {
        super.init(frame: frame)
//        self.delegate = delegate
        self.setUI()
    }
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }
    override func layoutSubviews() {
        super.layoutSubviews()
        self.titleView.snp.makeConstraints { (make) in
            make.left.equalTo(40)
            make.right.equalTo(-40)
            make.height.equalTo(30)
            make.top.equalTo(12)
        }
        self.bgView.snp.makeConstraints { (make) in
            make.left.equalTo(60)
            make.right.equalTo(-60)
            make.height.equalTo(100)
            make.top.equalTo(self.titleView.snp.bottom).offset(0)
        }
        self.noticeLabel.snp.makeConstraints { (make) in
            make.left.equalTo(16)
            make.right.equalTo(-16)
            make.top.equalTo(self.bgView.snp.bottom).offset(12)
            make.height.equalTo(self.height)
        }
    }
}
extension MineShareHeaDerView{
    func setUI(){
        self.backgroundColor = UIColor.init(red: 233/255.0, green: 233/255.0, blue: 233/255.0, alpha: 1.0)
       self.addSubview(self.titleView)
        self.addSubview(self.bgView)
        self.addSubview(self.infoLabel)
        self.addSubview(self.noticeLabel)
        //返回cell高度的计算
        self.height = self.infoLabel.jqGetHeightWithstr("没成功邀请1位用户(被邀请用户需注册并绑定手机号),邀请用户即可获得10徽币的奖励，所获徽币可以参与平台活动所获徽币可以参与平台活动所获徽币可以参与平台活动", withfontSize: 14, withLineSpace: 0, withmaxWidth: k_Wide - 32)
        self.noticeLabel.text = "没成功邀请1位用户(被邀请用户需注册并绑定手机号),邀请用户即可获得10徽币的奖励，所获徽币可以参与平台活动所获徽币可以参与平台活动所获徽币可以参与平台活动"
        self.noticeLabel.numberOfLines = 0
        self.noticeLabel.font = UIFont.systemFont(ofSize: 14)
        self.noticeLabel.textColor = .lightGray
//        if self.delegate != nil {
//            self.delegate?.returnHeightOfHeaderView(self.height + 12 + 12 + 12 + 100 + 30)
//        }
    }
}
